package Frames;

import classes.*;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class PrintF extends Frame {
    public PrintF(int foods[]){
        Frame frame=new Frame("膳食营养管理系统");
        frame.setVisible(true);
        frame.setSize(650,560);
        frame.setBackground(Color.WHITE);
        frame.setLocation(950,560);
        frame.setResizable(false);
        frame.setLayout(null);
        frame.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                frame.dispose();
            }
        });
        int energy=foods[0]* 125+foods[1]*100+foods[2]*40+foods[3]*50;
        int protein=foods[0]*25+foods[1]*19;
        int heat=foods[0]*150+foods[1]*118;
        int chole=foods[0]*81+foods[1]*106;
        int vitamin=foods[2]*80+foods[3]*120;
        int fiber=foods[2]*4+foods[3]*2;
        int water=foods[2]*60+foods[3]*55;
        Label energ=new Label("能量：  "+energy);
        Label prot=new Label("蛋白质： "+protein);
        Label hea=new Label("热量：  "+heat);
        Label chol=new Label("胆固醇： "+chole);
        Label vit=new Label("维生素： "+vitamin);
        Label fib=new Label("纤维：  "+fiber);
        Label wat=new Label("水分：  "+water);
        energ.setBounds(150,40,350,40);
        prot.setBounds(150,100,350,40);
        hea.setBounds(150,160,350,40);
        chol.setBounds(150,220,350,40);
        vit.setBounds(150,280,350,40);
        fib.setBounds(150,340,350,40);
        wat.setBounds(150,400,350,40);
        Font mF=new Font("",Font.BOLD,23);
        energ.setFont(mF);
        prot.setFont(mF);
        hea.setFont(mF);
        vit.setFont(mF);
        chol.setFont(mF);
        fib.setFont(mF);
        wat.setFont(mF);
        energ.setVisible(true);
        prot.setVisible(true);
        hea.setVisible(true);
        vit.setVisible(true);
        chol.setVisible(true);
        fib.setVisible(true);
        wat.setVisible(true);
        frame.add(energ);
        frame.add(prot);
        frame.add(hea);
        frame.add(vit);
        frame.add(chol);
        frame.add(fib);
        frame.add(wat);
        Button ok=new Button("确定");
        ok.setFont(new Font("",Font.BOLD,40));
        ok.setVisible(true);
        ok.setBounds(250,460,150,80);
        frame.add(ok);
        ok.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                frame.dispose();
            }
        });
        Label danwei=new Label("(标准单位)");
        danwei.setVisible(true);
        danwei.setFont(new Font("",Font.BOLD,20));
        danwei.setBounds(500,235,150,50);
        frame.add(danwei);

    }
}
